//替换所有的问号
//测试链接 https://leetcode.cn/problems/replace-all-s-to-avoid-consecutive-repeating-characters/
public class ModifyString {
    public String modifyString(String ss) {
        char[] s = ss.toCharArray();
        int n = s.length;

        for(int i = 0; i < n; i++){
            if(s[i] == '?'){  //遇到'？'才替换
                for(char temp = 'a' ; temp <= 'z'; temp++){
                    if((i == 0 || s[i-1] != temp) && (i == n-1 || s[i+1] != temp)){
                        s[i] = temp;
                        break;
                    }
                }
            }
        }
        return String.valueOf(s);
    }
}
